package cqrtplm.mapper;

import cqrtplm.entity.DspfMbomDetailDO;
import cqrtplm.vo.BuildEbomInfoVO;
import cqrtplm.vo.LikeBomVO;
import cqrtplm.vo.RtCfgBomPartDetailVO;
import cqrtplm.vo.RtCfgMzVO;
import feign.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * BOM详情体Mapper接口
 *
 * @author 江小熊
 * @date 2025-10-24
 */
public interface DspfMbomDetailMapper
{
    /**
     * 查询BOM详情体
     *
     * @param KID BOM详情体主键
     * @return BOM详情体
     */
    public DspfMbomDetailDO selectDspfMbomDetailByKID(String KID);

    /**
     * 查询BOM详情体列表
     *
     * @param dspfMbomDetail BOM详情体
     * @return BOM详情体集合
     */
    public List<DspfMbomDetailDO> selectDspfMbomDetailList(DspfMbomDetailDO dspfMbomDetail);

    /**
     * 新增BOM详情体
     *
     * @param dspfMbomDetail BOM详情体
     * @return 结果
     */
    public int insertDspfMbomDetail(DspfMbomDetailDO dspfMbomDetail);

    /**
     * 修改BOM详情体
     *
     * @param dspfMbomDetail BOM详情体
     * @return 结果
     */
    public int updateDspfMbomDetail(DspfMbomDetailDO dspfMbomDetail);

    /**
     * 删除BOM详情体
     *
     * @param kid BOM详情体主键
     * @return 结果
     */
    public int deleteDspfMbomDetailByKID(String kid);

    /**
     * 批量删除BOM详情体
     *
     * @param kids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteDspfMbomDetailByKIDs(String[] kids);

    int batchInsert(List<DspfMbomDetailDO> result);

    List<BuildEbomInfoVO> batchIbaByoids(@org.apache.ibatis.annotations.Param("oids") List<String> oids);

    RtCfgBomPartDetailVO getPartDetails(String nowOid);

    List<LikeBomVO> getRtCfgBOMByPartNumber(@Param("partNumber")String partNumber);

    List<LikeBomVO> getRtCfgBOMByDrawing(@Param("partNumber")String partNumber);

    List<String> getRtCfgBOMByDevCode(@Param("devCode")String devCode);

    String getTemplateCode(String oid);

    List<RtCfgMzVO> selectBytemplateCode(String templateCode);

    List<DspfMbomDetailDO> selectDspfMbomDetailListByBomid(@org.apache.ibatis.annotations.Param("bomid") String bomid,
                                                           @org.apache.ibatis.annotations.Param("nodeType") Integer nodeType);

    @Select("select count(*) from VIEW_TY_IBA iba \n" +
            "\tinner join TY_PART tp on iba.OBJBASEOID=tp.oid\n" +
            "\tinner join TY_PARTMASTER ma on ma.OID = tp.MASTEREDOID  where ma.PARTNUMBER=#{materialcode}")
    Integer selectIbaByNumber(@org.apache.ibatis.annotations.Param("materialcode") String materialcode);

    @Select("select count(*) from VIEW_TY_IBA iba \n" +
            "\tinner join TY_PART tp on iba.OBJBASEOID=tp.oid\n" +
            "\tinner join TY_PARTMASTER ma on ma.OID = tp.MASTEREDOID where ma.PARTNUMBER=#{materialcode} AND iba.attributeenname = 'ManufacturingProperties' and iba.attributevalue in ('1','4')")
    Integer selectIbaByPm(@org.apache.ibatis.annotations.Param("materialcode")String materialcode);

    @Select("select count(*) from VIEW_TY_IBA iba \n" +
            "\tinner join TY_PART tp on iba.OBJBASEOID=tp.oid\n" +
            "\tinner join TY_PARTMASTER ma on ma.OID = tp.MASTEREDOID where ma.PARTNUMBER=#{materialcode} AND iba.attributeenname = 'ManufacturingProperties' and iba.attributevalue in ('6')")
    Integer selectIbaBys(@org.apache.ibatis.annotations.Param("materialcode")String materialcode);

    List<DspfMbomDetailDO> selectDspfMbomDetailListByBomids(@org.apache.ibatis.annotations.Param("bomIds") List<String> bomIds);

    @Select("select ref.REFOBJBASEOID from TY_PARTMASTER tp join ty_referenceValue ref on tp .oid = ref.objbaseoid where tp.PARTNUMBER = #{objectNumber}")
    String selectRefobjbaseoidByNumber(@org.apache.ibatis.annotations.Param("objectNumber") String objectNumber);

    String selectRohsid(@org.apache.ibatis.annotations.Param("refobjbaseoid") String refobjbaseoid);

    String selectRohsValue(@org.apache.ibatis.annotations.Param("choid") String choid,
                           @org.apache.ibatis.annotations.Param("rohs")String rohs);

    Integer selectBomRepeat(@org.apache.ibatis.annotations.Param("bomIds") List<String> bomIds,
                                           @org.apache.ibatis.annotations.Param("kIds") List<String> kIds);
}
